#ifndef MAINSYSTEMWIDGET_H
#define MAINSYSTEMWIDGET_H

#include <QWidget>
#include <QStackedLayout>
#include "adminmanagement.h"
#include "commonusermanagement.h"
#include "devicemanagement.h"
#include "datamonitoring.h"
#include "alertmanagement.h"
#include "dataanalysis.h"
#include "systemsetting.h"
#include "logmanagement.h"
#include "databasemanager.h"
#include "usermanager.h"
#include "uart.h"

namespace Ui {
class MainSystemWidget;
}

class MainSystemWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MainSystemWidget(QWidget *parent = nullptr);
    ~MainSystemWidget();

    void switchToRole(int role);

private slots:
    void onUserManagementClicked();
    void onDeviceManagementClicked();
    void onDataMonitoringClicked();
    void onAlertManagementClicked();
    void onDataAnalysisClicked();
    void onSystemSettingClicked();
    void onLogManagementClicked();
    void onUartMangementClicked();

private:
    void initialize();
    void initUIComponents();
    void setupConnections();

    Ui::MainSystemWidget *ui;
    DatabaseManager* m_pDatabaseManager;
    UserManager* m_pUserManager;
    QStackedLayout* m_pStackedLayout;

    // 功能页面
    AdminManagement* m_pAdminManagement;
    CommonUserManagement* m_pCommonUserManagement;
    DeviceManagement* m_pDeviceManagement;
    DataMonitoring* m_pDataMonitoring;
    AlertManagement* m_pAlertManagement;
    DataAnalysis* m_pDataAnalysis;
    SystemSetting* m_pSystemSetting;
    LogManagement* m_pLogManagement;
    Uart* m_pUart;
};

#endif // MAINSYSTEMWIDGET_H
